<template>
  <div class="tabbar">
    <mt-tabbar v-model="selected" fixed>
      <mt-tab-item id="/">
        <i class="tabbar__icon iconfont icon-borrow"></i>
        借款
      </mt-tab-item>
      <mt-tab-item id="refund">
        <i class="tabbar__icon iconfont icon-refund"></i>
        还款
      </mt-tab-item>
      <mt-tab-item id="me">
        <i class="tabbar__icon iconfont icon-me"></i>
        我的
      </mt-tab-item>
    </mt-tabbar>
  </div>
</template>
<script>
  export default {
    data() {
      return {
        selected: '/'
      }
    },
    watch: {
      selected(nV, oV) {
        if (nV !== oV) {
          this.$router.push(nV)
        }
      }
    },
    created() {
      setTimeout(()=>{
        let routeName = this.$route.name
        this.selected = routeName && routeName!=='home' ? routeName : '/'
      },50)
    }
  }
</script>